package com.liangzhen.verynews.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.widget.Toast;

public class ConnectityUtils {
	private static ConnectivityManager connectivityManager;

	public static boolean isConection(Context context) {
		boolean flag = false;
		connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo mobileInfo =connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo wifiInfo =connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		if (mobileInfo!=null&&mobileInfo.isConnected()) {
			Toast.makeText(context, "手机网络连接", Toast.LENGTH_SHORT).show();
			flag=true;
		}else if (wifiInfo!=null&&wifiInfo.isConnected()) {
			Toast.makeText(context, "wifi连接", Toast.LENGTH_SHORT).show();
			flag=true;
		}else {
			flag=false;
		}
		return flag;
	}

}
